package simple

func backspaceCompare(s string, t string) bool {
	var stack []byte
	var stack2 []byte
	for _, b := range s {
		if b == '#' {
			if len(stack) > 0 {
				stack = stack[:len(stack)-1]
			}
		} else {
			stack = append(stack, byte(b))
		}
	}

	for _, b := range t {
		if b == '#' {
			if len(stack2) > 0 {
				stack2 = stack2[:len(stack2)-1]
			}
		} else {
			stack2 = append(stack2, byte(b))
		}
	}

	return string(stack) == string(stack2)
}
